<template>
  <div>
    <NavBar>
      <div slot="left" class="back" @click="back">
        <img src="~assets/img/common/back.svg" alt="">
      </div>
      <div slot="center" class="title">
        <div
          class="title-item"
          v-for="(item, index) in title"
          :key="index"
          :class="{ active: index === currentIndex }"
          @click="high(index)"
        >
          {{ item }}
        </div>
      </div>
    </NavBar>
  </div>
</template>

<script>
import NavBar from "components/common/navbar/NavBar";

export default {
  name: "DetailNavBar",
  components: { NavBar },
  data() {
    return {
      title: ["商品", "参数", "评论", "推荐"],
      currentIndex: 0,
    };
  },
  methods: {
    high(index) {
      this.currentIndex = index;
      this.$emit('titleClick',index)
    },
    back(){
        this.$router.back()
    }
  },
};
</script>

<style scoped>
.back img{
    margin-top: 12px;
    margin-left: 16px;
}
.title {
  display: flex;
  color: gray;
}
.title-item {
  flex: 1;
}
.active {
  color: var(--color-high-text);
}
</style>
